package PTA3.ti4;
import java.util.*;

/**
 * @author Lenovo
 */

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        Shape[] shapes = new Shape[n];
        for (int i = 0; i < n; ++i) {
            String type = sc.nextLine();
            switch (type) {
                case "rect": {
                    String[] digit = sc.nextLine().split(" ");
                    int width = Integer.parseInt(digit[0]);
                    int length = Integer.parseInt(digit[1]);
                    shapes[i] = new Rectangle(width, length);
                    break;
                }
                case "cir": {
                    int radius = sc.nextInt();
                    sc.nextLine();
                    shapes[i] = new Circle(radius);
                    break;
                }
            }
        }
        System.out.println(sumAllPerimeter(shapes));
        System.out.println(sumAllArea(shapes));
        System.out.println(Arrays.toString(shapes));
        for (Shape shape : shapes) {
            System.out.println(shape.getClass() + "," + shape.getClass().getSuperclass());
        }
        sc.close();
    }

    public static double sumAllArea(Shape[] shapes) {
        double sumArea = 0;
        for (Shape shape : shapes) {
            sumArea += shape.getArea();
        }
        return sumArea;
    }

    public static double sumAllPerimeter(Shape[] shapes) {
        double sumPerimeter = 0;
        for (Shape shape : shapes) {
            sumPerimeter += shape.getPerimeter();
        }
        return sumPerimeter;
    }
}

abstract class Shape {
    public static final double PI = 3.14;
    public abstract double getPerimeter();
    public abstract double getArea();
}

class Rectangle extends Shape {
    int width;
    int length;

    public Rectangle(int width, int length) {
        this.width = width;
        this.length = length;
    }

    @Override
    public double getPerimeter() {
        return 2 * (width + length);
    }

    @Override
    public double getArea() {
        return width * length;
    }

    @Override
    public String toString() {
        return "Rectangle [width=" + width + ", length=" + length + "]";
    }
}

class Circle extends Shape {
    int radius;

    public Circle(int radius) {
        this.radius = radius;
    }

    @Override
    public double getPerimeter() {
        return 2 * PI * radius;
    }

    @Override
    public double getArea() {
        return PI * radius * radius;
    }

    @Override
    public String toString() {
        return "Circle [radius=" + radius + "]";
    }
}